import request from '@/utils/request'

// 查询商品属性列表
export function listAttr(query) {
  return request({
    url: '/goods/attr/list',
    method: 'get',
    params: query
  })
}

// 查询商品属性详细
export async function getAttr(attrId) {
  return request({
    url: '/goods/attr/' + attrId,
    method: 'get'
  })
}

// 新增商品属性
export function addAttr(data) {
  return request({
    url: '/goods/attr',
    method: 'post',
    data: data
  })
}

// 修改商品属性
export function updateAttr(data) {
  return request({
    url: '/goods/attr',
    method: 'put',
    data: data
  })
}

// 删除商品属性
export function delAttr(attrId) {
  return request({
    url: '/goods/attr/' + attrId,
    method: 'delete'
  })
}

// 获取商品属性选择框列表
export function optionselect() {
  return request({
    url: '/goods/attr/optionselect',
    method: 'get'
  })
}

// 获取商品属性菜单选择框列表
export function optionMenuselect() {
  return request({
    url: '/goods/attr/optionMenuselect',
    method: 'get'
  })
}

export function treeSelect() {
  return request({
    url: '/goods/attr/treeSelect',
    method: 'get'
  })
}

export function typeAttrTreeSelect(typeId) {
  return request({
    url: '/goods/attr/typeAttrTreeSelect/' + typeId,
    method: 'get'
  })
}

export function findAttrsWithoutConfig(param) {
  return request({
    url: '/goods/attr/findAttrsWithoutConfig',
    method: 'post',
    data: param
  })
}


export function typeAttrTreeOptions(typeId) {
  return request({
    url: '/goods/attr/typeAttrTreeOptions/' + typeId,
    method: 'get'
  })
}


// 查询商品属性最大顺序值
// export function findMaxOrderNum(attrId) {
//   return request({
//     url: '/goods/attrval/findMaxOrderNum/' + attrId,
//     method: 'get'
//   })
// }
